Getting started

Adding DataObjects.Net to your projects

Creating new project from template

This scenario requires DataObjects.Net to be installed onto the computer. For more information about where to get the installer, see Using installer section. The package installs a set of DataObjects.Net project templates to choose from. Open Visual Studio.NET, click File New Project. You will see the following project templates:

_images/ProjectTemplates.png

Select a templates to create the project based on it.

Adding DataObjects.Net to an existing project

  1. Open NuGet Package Manager and search for DataObjects.Net:
_images/NuGet.png
  1. Install DataObjects.Net package.

    The package will automatically install all dependencies and DataObjects.Net will be ready for use with MS SQL Server as a default storage.

  2. Install desired data providers (optional).

    In case you want to use DataObjects.Net with data provider other than MS SQL Server, install the desired provider from the list of DataObjects.Net packages.

  3. Install DataObjects.Net extensions (optional).

    Extensions are small projects that extend standard functionality of DataObjects.Net core.

NuGet-based way is portable, it doesn’t require to have DataObjects.Net installed on machine.

Under the hood

For a project to be a valid DataObjects.Net project, it should meet some specific requirements. Project templates provided by DataObjects.Net installer already contain all necessary changes, whereas NuGet packages apply them on the fly when the corresponding NuGet package is being installed.

Anyway, here are the requirements so you can get familiar with them:

  1. Project should reference PostSharp, Xtensive.Aspects, Xtensive.Core, Xtensive.Orm assemblies.

    _images/ProjectReferences.png

    Xtensive.* assemblies are core parts of DataObjects.Net whilst PostSharp is a standalone component and used here to inject persistence-related aspects into domain model entities. More about PostSharp and its features can be found on its official website.

  2. Project should import DataObjects.Net.targets file. The file contains a bunch of MSBuild tasks that are executed during project build process. Depending on whether the project is created from DataObjects.Net project template or DataObjects.Net was added via NuGet, the path to the file may vary in the following ways:

    • Importing DataObjects.Net.targets when project file is created from template. As DataObject.Net was installed onto the machine, DataObjects.Net.targets was placed to MSBuildExtensionsPath directory which usually corresponds to C:\Program Files\MSBuild path. So import directive in csproj file looks like this:

      <Import Project="$(MSBuildExtensionsPath)\DataObjects.Net\v4.6\DataObjects.Net.targets" />
      
    • Importing DataObjects.Net.targets when DataObjects.Net was added via NuGet. Packages are installed to a directory relative to the project directory. Import directive looks like this;

      <Import Project="..\packages\Xtensive.Orm.4.6.0\DataObjects.Net.targets" />